import request from '@/utils/request'

// 获取地址
export function addCart(list,userId) {
   const data = {
      list: list,
      userId: userId
    };
  return request({
    'url': `/cart/add`,
     'method': 'post',
	    data: JSON.stringify(data),
  })
}

export function getCart(userId) {
   const cartId=userId;
  return request({
    'url': `/cart/products/${cartId}`,
     'method': 'get',
  })
}

export function getStock(skuId) {
   // const cartId=userId;
  return request({
    'url': `/cart/stock/${skuId}`,
     'method': 'get',
  })
}

export function deleteById(ids) {
   // const cartId=userId;
  return request({
    url: `/cart/delete`,
    method: 'post',
	 header: {
	      'content-type': 'application/json' // 设置请求头为 JSON
	    },
	 data: ids
  })
}
export function update(id, quantity) {
  return request({
    url: `/cart/update`,
    method: 'get',
    params: {
      id: id,
      quantity: quantity
    }
  });
}